package com.md.mapper;

import com.md.entity.Course;
import com.md.entity.Teacher;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CourseMapper {
    @Select("select * from course where course_id=#{id}")
    @Results({
            @Result(column = "teacher_id",property = "teacherId"),
            @Result(column = "teacher_id",property = "teacher",one=@One(select = "com.md.mapper.TeacherMapper.selectOneTeacherById"))
    })
    Course selectOneCourse(int id);

    @Select("select * from course where teacher_id=#{id}")
    List<Course> selectCourseByTeacherId(int id);
}
